﻿
@{
    Layout = null;
}

<!DOCTYPE html>


<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        .ibox {
            margin-bottom: 0px;
        }

        .ibox-content {
            padding: 15px 20px 0px 20px;
        }

        /*.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12,
        .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12,
        .btn-group {
            border-style: solid;
            border-width: 1px;
            border-color: #000;
        }*/

        #conditionDiv, .col-xs-10, #AreaDiv {
            padding-left: 0px;
            padding-right: 0px;
        }

        #PropertyType {
            margin-right: 15px;
        }

        .col-xs-2 {
            padding-left: 0px;
            padding-right: 0px;
            text-align: right;
        }

        #commissionBtnDiv { 
            float:right;
            margin-left:20px;
        }

        .form-group {
            margin-bottom: 0px;
        }

        #ProvinceDiv, #CityDiv, #DistrictDiv, #WhetherOnlineDiv, #PropertyTypeDiv {
            padding-left: 0px;
            padding-right: 0px;
        }

        #PropertyTypeLaber, #PropertyTypeSelect, #WhetherOnlineLaber, #WhetherOnlineSelect {
            padding-left: 0px;
            padding-right: 0px;
            text-align: right;
        }

        #selectDiv {
            padding-left: 0px;
        }

        #SecondDiv {
            padding-left: 0px;
        }
    </style>

</head>
<body class="gray-bg"> 
    <div class="wrapper wrapper-content animated fadeInRight" style="padding:10px;">
        <div class="ibox float-e-margins">
            <div class="panel panel-default" style="margin-top:10px;margin-bottom:10px;">
                <div class="panel-heading">
                    <strong>查询条件</strong>
                </div>
                <div class="panel-body">
                    <div class="col-sm-10" id="conditionDiv">
                        <div class="col-sm-10" id="SecondDiv">
                            <div class="col-sm-6" id="AreaDiv">
                                <div class="form-group col-sm-4" id="ProvinceDiv">
                                    <label class="col-xs-2 control-label" style="float:left; margin-top:8px;">省：</label>
                                    <div class="col-xs-10">
                                        <select class="form-control" name="Province" id="Province">
                                            <option value="">省份</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-4" id="CityDiv">
                                    <label class="col-xs-2 control-label" style="float:left; margin-top:8px;">市：</label>
                                    <div class="col-xs-10">
                                        <select class="form-control" name="City" id="City">
                                            <option value="">城市</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group col-sm-4" id="DistrictDiv">
                                    <label class="col-xs-2 control-label" style="float:left; margin-top:8px;">区：</label>
                                    <div class="col-xs-10">
                                        <select class="form-control" name="District" id="District">
                                            <option value="">地区</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group col-sm-3" id="WhetherOnlineDiv">
                                <label class="col-xs-4 control-label" style="float:left; margin-top:8px;" id="WhetherOnlineLaber">是否上线：</label>
                                <div class="col-xs-8" id="WhetherOnlineSelect">
                                    <select class="form-control" name="WhetherOnline" id="WhetherOnline">
                                        <option value='0'>全部</option>
                                        <option value='1'>已上线</option>
                                        <option value='2'>即将上线</option>
                                        <option value='3'>未上线</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group col-sm-3" id="PropertyTypeDiv">
                                <label class="col-xs-4 control-label" id="PropertyTypeLaber" style="float:left; margin-top:8px;">楼盘类型：</label>
                                <div class="col-xs-8" id="PropertyTypeSelect">
                                    <select class="form-control" name="PropertyType" id="PropertyType">
                                        <option value='0'>全部</option>
                                        <option value='1'>住宅</option>
                                        <option value='2'>商业</option>
                                        <option value='3'>旅游地产</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>



            <div class="ibox-content">
                <div class="col-sm-2" style="padding:0px;">
                    <div class="btn-group">
                        <button id="insertBtn" type="button" class="btn btn-outline btn-default">
                            <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
                        </button>
                        <button id="editBtn" type="button" class="btn btn-outline btn-default">
                            <i class="glyphicon glyphicon-edit" aria-hidden="true"></i>
                        </button>
                        <button id="deleteBtn" type="button" class="btn btn-outline btn-default">
                            <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
                        </button>
                        <button id="refreshBtn" type="button" class="btn btn-outline btn-default">
                            <i class="glyphicon glyphicon-refresh" aria-hidden="true"></i>
                        </button>

                        <div id="commissionBtnDiv">
                            <button id="CommissionBtn" type="button" class="btn btn-primary">
                                佣金修改
                            </button>
                        </div>
                    </div>
                </div>
                <table id="table" data-mobile-responsive="true"></table>
            </div>
        </div>
        @* 用来传递消息的隐藏域 *@
        <input id="GroupID" value="@ViewBag.GroupID" hidden="hidden">
    </div>

    <!-- 全局js -->
    <script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script type="text/javascript" src="~/Scripts/content.js?v=1.0.0"></script>
    <!-- Bootstrap table -->
    <script type="text/javascript" src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
    <script src="~/Scripts/plugins/bootstrap-table/extensions/export/tableExport.jquery.plugin-master/tableExport.js"></script>
    @*<script src="~/Scripts/plugins/bootstrap-table/extensions/export/bootstrap-table-export.min.js"></script>*@
    <script type="text/javascript" src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script src="~/Scripts/plugins/layer/laydate/laydate.js"></script>

    @*<script src="~/Areas/Account/Scripts/BrokerageList.js?@DateTime.Now.ToString("yyyyMMddHHmmssfff")"></script>*@
    <script src="~/Scripts/TimeObjectUtil.js"></script>
    <script src="~/Scripts/plugins/multiselect/bootstrap-multiselect.js"></script>
    <script src="~/Scripts/loginmodel.js"></script>

    <script type="text/javascript">
        $(function () {
            initTable();
            if (isAuthority('137')) {
                $('#insertBtn').show();
                $('#editBtn').show();
                $('#deleteBtn').show();
            }
            else {
                $('#insertBtn').hide();
                $('#editBtn').hide();
                $('#deleteBtn').hide();
            }

            if (isAuthority('138')) {
                $('#CommissionBtn').show();
            }
            else {
                $('#CommissionBtn').hide();
            }
        });

        var $table = $("#table");

        function initTable() {
            $table.bootstrapTable({
                url: '/NewHouse/Buildings/IndexListAsync',            //数据来源地址
                method: 'post',                     //数据请求方式
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否启用分页
                sidePagination: 'server',           //在服务器端分页
                queryParams: queryParams,           //传递参数
                pageNumber: 1,                      //初始化加载第一页，默认第一页
                pageSize: 20,                       //每页的记录行数（*）
                pageList: [10, 20, 30, 40, 50, 'All'],     //可供选择的每页的行数（*）
                clickToSelect: true,                //是否启用点击选中行
                //toolbar: "#tableToolBar",
                height: getHeight(),
                search: true,
                showRefresh: true,
                showColumns: true,
                showExport: true,                     //是否显示导出
                exportDataType: "basic",              //basic', 'all', 'selected'.
                exportTypes: ['excel'],
                exportOptions: { fileName: '新房房源列表' },
                toolbar: '#exampleToolbar',
                iconSize: 'outline',
                icons: {
                    refresh: 'glyphicon-repeat',
                    columns: 'glyphicon-list'
                },
                toolbar: '#exampleToolbar',
                columns: [{
                    width: 38,
                    field: 'selected',
                    checkbox: true,
                }, {
                    field: 'id',
                    title: '行号',
                    align: 'center',
                    cellStyle: function cellStyle(value, row, index) {

                        if (row.showIndex > 0) {
                            return {
                                css: {
                                    "font-weight": "bold", "color": "red"
                                }
                            };
                        }
                        return {};

                    },
                }, {
                    field: 'state',
                    title: '状态',
                    align: 'center',
                    formatter: stateFormatter
                }, {
                    field: 'name',
                    title: '楼盘名称',
                    align: 'center'
                }, {
                    field: 'address',
                    title: '楼盘地址',
                    align: 'center'
                }, {
                    field: 'sellingPrice',
                    title: '售价',
                    align: 'center'
                }, {
                    field: 'remark',
                    title: '楼盘说明',
                    align: 'center'
                }, {
                    field: 'buildingType',
                    title: '类型',
                    align: 'center'
                }, {
                    field: 'mediumOfCommunicationStaff',
                    title: '渠道人员',
                    align: 'center'
                }, {
                    field: 'stationedStaff',
                    title: '驻场人员',
                    align: 'center'
                }, {
                    field: 'starTarget',
                    title: '结算模式',
                    align: 'center',
                    formatter: starTargetFormatter
                }, {
                    field: 'starTargetRemark',
                    title: '星标备注',
                    align: 'center',
                    visible: false, 
                }, {
                    title: '佣金',
                    align: 'center',
                    formatter: SellingBrokerageFormatter
                }, {
                    field: 'commissionAccount',
                    title: '佣金帐期',
                    align: 'center'
                }, {
                    field: 'district',
                    title: '区',
                    align: 'center'
                },
                //{
                //    field: 'beginTime',
                //    title: '开始时间',
                //    align: 'center'
                //}, {
                //    field: 'endTime',
                //    title: '结束时间',
                //    align: 'center'
                //}, {
                //    field: 'showIndex',
                //    title: '排序',
                //    align: 'center'
                //}, {
                //    field: 'createdTime',
                //    title: '时间',
                //    align: 'center'
                //},
                {
                    title: '地图坐标',
                    align: 'center',
                    formatter: MapCoordinateFormatter
                }, {
                    title: '更多资料',
                    align: 'center',
                    formatter: ButtonFormatter
                }]
            });
        }
        //查询的参数
        var queryParams = function (params) {
            var temp = {
                pageSize: params.limit,                             //行数
                pageIndex: (params.offset / params.limit) + 1,      //页码
                search: params.search,
                Province: $('#Province').val(),
                City: $('#City').val(),
                District: $('#District').val(),
                WhetherOnline: $('#WhetherOnline').val(),
                PropertyType: $('#PropertyType').val(),
            };
            //console.info(temp);
            return temp;
        };
        //获取表格高度
        function getHeight() {
            return $(window).height() - 150;
        }
        //刷新表格数据
        var refreshTable = function () {
            $table.bootstrapTable("refresh");
        }
        //刷新按钮
        $("#refreshBtn").click(function (e) {
            $table.bootstrapTable("refresh");
        });
        $('#WhetherOnline').change(function (e) {
            $table.bootstrapTable('refresh');
        });
        $('#Province').change(function (e) {
            $table.bootstrapTable('refresh');
        });
        $('#City').change(function (e) {
            $table.bootstrapTable('refresh');
        });
        $('#District').change(function (e) {
            $table.bootstrapTable('refresh');
        });
        $('#PropertyType').change(function (e) {
            $table.bootstrapTable('refresh');
        });
        //搜索按钮
        $("#searchBtn").click(function (e) {
            $table.bootstrapTable("refresh");
        });
        //更多资料
        function ButtonFormatter(value, row, index) {
            return [
                '<div class="btn-group">',
                    '<button data-toggle="dropdown" class="btn  btn-info btn-sm dropdown-toggle" aria-expanded="false">',
                        '更多资料 <span class="caret"></span>',
                    '</button>',
                    '<ul class="dropdown-menu">',
                        ' <li>',
                            '<a href="javascript:void(0)"  onclick="PropertyDetailseditData(' + row.id + ')">楼盘详情</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(2)"  onclick="PropertyInformationeditData(' + row.id + ')">楼盘信息</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(3)"  onclick="DeveloperRuleeditData(' + row.id + ')">开发商规则</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(4)"  onclick="BuyingPointeditData(' + row.id + ')">买点</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(5)"  onclick="ListOfUnitseditData(' + row.id + ')">户型列表</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(6)"  onclick="BrokerageList(' + row.id + ')">佣金分组</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(7)"  onclick="InformationList(' + row.id + ')">跟进信息</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(7)"  onclick="InformationList(' + row.id + ')">置业顾问</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(7)"  onclick="TopEditData(' + row.id + ',' + row.buildingTopID + ')">置顶操作</a>',
                        '</li>',
                        '<li>',
                            '<a href="javascript:selecttime(7)"  onclick="PictureManagementeditData(' + row.id + ')">图片管理</a>',
                        '</li>',
                    '</ul>',
                '</div>',
            ].join('');
        }
        //跟进信息
        function InformationList(id) {
            parent.layer.open({
                type: 2,
                title: '跟进信息',
                shadeClose: false,
                shade: 0.4,
                area: ['1400px', '720px'],
                content: '/Organization/MessageBoards/Index?InterfixID=' + id + '&MessageBoardsType=' + 2,
                end: function () {
                    refreshTable();
                }
            });
        }
        //置业顾问
        function InformationList(id) {
            parent.layer.open({
                type: 2,
                title: '置业顾问',
                shadeClose: false,
                shade: 0.4,
                area: ['1400px', '720px'],
                content: '/NewHouse/PropertyConsultant/Index?BuildingID=' + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        //地图坐标
        function MapCoordinateFormatter(value, row, index) {
            return [
                    '<a class="kv-file-zoom btn btn-xs btn-primary" href="javascript:void(0)"  onclick="MapCoordinate(' + row.id + ')">',
                    '地图坐标',
                    '</a>  ',
            ].join('');
        }
        function MapCoordinate(id) {
            parent.layer.open({
                type: 2,
                title: "地图坐标",
                shadeClose: false,
                shade: 0.4,
                area: ["830px", "600px"],
                content: "/NewHouse/Buildings/EditMapCoordinate?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        ////佣金分组
        function BrokerageList(id) {
            parent.layer.open({
                type: 2,
                title: '佣金分组',
                shadeClose: false,
                shade: 0.4,
                area: ['960px', '750px'],
                content: '/Account/Brokerage/BrokerageGroupList?ModuleID=' + 1 + '&ItemID=' + id,
                end: function () {
                    refreshTable();
                }
            });

        }
        //佣金
        function SellingBrokerageFormatter(value, row, index) {
            return [
                '<a class="kv-file-zoom" href="javascript:void(0)"  onclick="SellingBrokerageditData(' + row.id + ')">',
                row.sellingBrokerage,
                '</a>  ',
            ].join('');
        }
        function SellingBrokerageditData(id) {
            parent.layer.open({
                type: 2,
                title: "修改历史",
                shadeClose: false,
                shade: 0.4,
                area: ["880px", "350px"],
                content: "/NewHouse/Buildings/Commission?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        ////楼盘详情
        function PropertyDetailseditData(id) {
            parent.layer.open({
                type: 2,
                title: "楼盘详情",
                shadeClose: false,
                shade: 0.4,
                area: ["950px", "650px"],
                content: "/NewHouse/Buildings/EditPropertyDetailsedit?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        ////楼盘信息
        function PropertyInformationeditData(id) {
            parent.layer.open({
                type: 2,
                title: "楼盘信息",
                shadeClose: false,
                shade: 0.4,
                area: ["380px", "660px"],
                content: "/NewHouse/Buildings/EditPropertyInformationeditData?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        ////开发商规则
        function DeveloperRuleeditData(id) {
            parent.layer.open({
                type: 2,
                title: "开发商规则",
                shadeClose: false,
                shade: 0.4,
                area: ["1080px", "630px"],
                content: "/NewHouse/Buildings/EditDeveloperRuleeditData?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        ////买点
        function BuyingPointeditData(id) {
            parent.layer.open({
                type: 2,
                title: "买点",
                shadeClose: false,
                shade: 0.4,
                area: ["880px", "700px"],
                content: "/NewHouse/Buildings/EditBuyingPointeditData?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        ////户型列表
        function ListOfUnitseditData(id) {
            parent.NewHouse_HouseType_Index_Id = id;
            parent.OpenNewTab("/NewHouse/HouseType/Index", "id=" + id);
            // window.open("/NewHouse/HouseType/Index?id=" + id);
        }
        ////图片管理
        function PictureManagementeditData(id) {
            parent.layer.open({
                type: 2,
                title: "相册",
                shadeClose: false,
                shade: 0.4,
                area: ["960px", "820px"],
                content: '/Images/Index?GroupID=' + 1 + '&InterfixID=' + id + '&ImageType=' + 0,
                end: function () {
                    refreshTable();
                }
            });
        }
        //置顶操作
        function TopEditData(id, buildingTopID) {
            parent.layer.open({
                type: 2,
                title: "置顶",
                shadeClose: false,
                shade: 0.4,
                area: ["350px", "400px"],
                content: '/NewHouse/Buildings/EditTopData?UnionModule=' + 1 + '&UnionID=' + id + '&BuildingTopID=' + buildingTopID,
                end: function () {
                    refreshTable();
                }
            });
        }
        //结算模式
        function starTargetFormatter(value, row, index) {
            if (value == 0) {
                var str = "无";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-default" href="javascript:void(0)"  onclick="starTargetSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }
            if (value == 1) {
                var str = "前佣";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-primary" href="javascript:void(0)"  onclick="starTargetSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }
            if (value == 2) {
                var str = "后佣";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-success" style="background-color: #55a2ed;" href="javascript:void(0)"  onclick="starTargetSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }
            if (value == 3) {
                var str = "前佣_后佣";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-danger" href="javascript:void(0)"  onclick="starTargetSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }
            if (value == 4) {
                var str = "其他";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-default" style="background-color: #dc5fce;" href="javascript:void(0)"  onclick="starTargetSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }

        }
        //结算模式设置
        function starTargetSet(value, id) {
            parent.layer.open({
                type: 2,
                title: "结算模式",
                shadeClose: false,
                shade: 0.4,
                area: ["650px", "260px"],
                content: "/NewHouse/Buildings/SetStarTarget?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        //设置在线
        function stateFormatter(value, row, index) {
            if (value == 1) {
                var str = "在线";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-primary" href="javascript:void(0)"  onclick="stateSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }
            if (value == 2) {
                var str = "下线";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-danger" href="javascript:void(0)"  onclick="stateSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }
            if (value == 3) {
                var str = "即将上线";
                return [
              '<a class="kv-file-zoom btn btn-xs btn-warning" href="javascript:void(0)"  onclick="stateSet(' + value + ',' + row.id + ')">',
              '<i">' + str + '</i>',
              '</a>  '
                ].join('');
            }
        }
        //设置在线，下线
        function stateSet(value, id) {
            parent.layer.open({
                type: 2,
                title: "状态",
                shadeClose: false,
                shade: 0.4,
                area: ["350px", "180px"],
                content: "/NewHouse/Buildings/StateSet?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        //类型
        function BuildingTypeFormatter(value, row, index) {

            if (value == 1) {
                return ['住宅'].join('');
            }
            if (value == 2) {
                return ['旅游地产'].join('');
            }
            if (value == 3) {
                return ['门市'].join('');
            }
            if (value == 3) {
                return ['商铺'].join('');
            }
        }
        //租售类型
        function letSellTypeFormatter(value, row, index) {

            if (value == 1) {
                return ['出租'].join('');
            }
            if (value == 2) {
                return ['销售'].join('');
            }
            if (value == 3) {
                return ['租售'].join('');
            }
        }
        //佣金修改按钮
        $('#CommissionBtn').click(function (e) {
            var selected = $table.bootstrapTable("getSelections");
            if (selected.length > 1) {
                layer.msg("一次只能修改一条数据！", { icon: 5, time: 2000 });
                return;
            }

            if (selected.length == 0) {
                layer.msg("请选择您要修改的数据！", { icon: 5, time: 2000 });
                return;
            }
            var id = selected[0].id;
            parent.layer.open({
                type: 2,
                title: "修改佣金",
                shadeClose: false,
                shade: 0.4,
                area: ["750px", "250px"],
                content: "/NewHouse/Buildings/EditCommission?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        });
        //插入按钮
        $("#insertBtn").click(function (e) {
            parent.layer.open({
                type: 2,
                title: "添加楼盘",
                shadeClose: false,
                shade: 0.4,
                area: ["850px", "530px"],
                content: "/NewHouse/Buildings/InsertList",
                end: function () {
                    refreshTable();
                }
            });
        });
        //编辑按钮
        $("#editBtn").click(function (e) {
            var selected = $table.bootstrapTable("getSelections");

            if (selected.length > 1) {
                layer.msg("一次只能修改一条数据！", { icon: 5, time: 2000 });
                return;
            }

            if (selected.length == 0) {
                layer.msg("请选择您要修改的数据！", { icon: 5, time: 2000 });
                return;
            }
            editData(selected[0].id);
        });
        //打开编辑窗口
        function editData(id) {
            parent.layer.open({
                type: 2,
                title: "修改楼盘",
                shadeClose: false,
                shade: 0.4,
                area: ["850px", "530px"],
                content: "/NewHouse/Buildings/EditList?id=" + id,
                end: function () {
                    refreshTable();
                }
            });
        }
        //删除按钮
        $("#deleteBtn").click(function (e) {
            var selected = $table.bootstrapTable("getSelections");
            if (selected.length == 0) {
                layer.msg("请选择您要删除的数据！", { icon: 5, time: 2000 });
                return;
            }

            var arr = [];
            for (var i = 0; i < selected.length; i++) {
                arr.push(selected[i].id);
            }

            var ids = arr.join(",");
            DeletedData(ids)
        });
        function DeletedData(ids) {
            layer.confirm("您确定要删除所选数据吗", {
                btn: ["是的", "取消"] //按钮
            }, function () {
                $.ajax({
                    url: "/NewHouse/Buildings/DeleteListAsync",
                    type: "post",
                    dataType: "json",
                    data: { ids: ids },
                    success: function (data) {
                        //Info,Success,Warning,Error
                        var type = data.type;
                        if (type == 1) {
                            layer.msg(data.content,
                                {
                                    icon: 6, time: 2000
                                },
                                function () {
                                    refreshTable();
                                });
                        } else {
                            layer.msg(data.content, { icon: 5, time: 2000 });
                        }
                    }
                });
            }, function () {
                return;
            });
        }

        GetProvince();//加载省份
        $("#Province").change(function () { GetCity() });//加载城市
        $("#City").change(function () { GetDistrict() });//加载区县


        function GetProvince() {
            $("#Province").empty();//清空省份SELECT控件
            $.getJSON("/NewHouse/Buildings/GetProvincelist", function (data) {
                $("<option></option>").val("").text("省份").appendTo($("#Province"));
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#Province"));
                })
                GetCity();
            });
        }
        function GetCity() {
            $("#City").empty();//清空城市SELECT控件
            $.getJSON(
            "/NewHouse/Buildings/GetCitylist",
            { pid: $("#Province").val() },
            function (data) {
                $("<option></option>").val("").text("城市").appendTo($("#City"));
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#City"));
                })
                GetDistrict();
            });
        }
        function GetDistrict() {
            $("#District").empty();//清空区县SELECT控件
            $.getJSON(
                "/NewHouse/Buildings/GetDistrictlist",
                {
                    cid: $("#City").val()
                },
                function (data) {
                    $("<option></option>").val("").text("区域").appendTo($("#District"));
                    $.each(data, function (i, item) {
                        $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#District"));
                    })
                });
        }
        //截取长度
        function CutOut(value, row, index) {
            if (value.length > 7) {
                value = value.substring(0, 5) + '..';
            }
            return [
               value
            ].join('');
        }
    </script>
</body>

</html>